import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

public class Demo5 {

//    private static BlockingQueue<Integer> blockingQueue = new LinkedBlockingQueue<>(100);

    private static test t = new test(100);

    public static void main(String[] args) {

        Thread creat = new Thread(() -> {

            int p = 0;


//            try {
                while (true) {
//                        Thread.sleep(1000);

                    t.put(p);
                    System.out.println("生产者生产：" + p);
                    p++;
                }
//            } catch (InterruptedException e) {
//                throw new RuntimeException(e);
//            }


        },"cre");

        Thread colunm = new Thread(() -> {

//            try {
                while (true) {

//                        Thread.sleep(1000);
                    int p = t.take();

                    System.out.println("消费者消费：" + p);
                }
//            } catch (InterruptedException e) {
//                throw new RuntimeException(e);
//            }

        },"col");

        creat.start();
        colunm.start();
    }
}
